<?php
/**
 * Created by PhpStorm.
 * User: gyq
 * Date: 2018/11/17
 * Time: 11:22
 */

namespace app\api\controller\v1;


use app\api\controller\BaseController;
use app\api\service\WxNotify;
use app\api\validate\IDMustBePositiveInt;
use app\api\service\Pay as PayService;

class Pay extends BaseController
{
    protected $beforeActionList = [
        'checkExclusiveScope' => ['only' => 'getPreOrder']
    ];

// pay/pre_order
    public function getPreOrder($id = '')
    {
        (new IDMustBePositiveInt())->goCheck();
        $payService = new PayService($id);
        $res = $payService->pay();
        return json($res, 200);
    }

    public function receiveNotify()
    {
//        检测库存量
//        更新status状态
//        减库存
        $notify = new WxNotify();
        $notify->Handle();
    }
}